﻿using UnityEngine;
using FastDev;
using System.Collections.Generic;

public class EatAction : GoapAction
{
    public override string Name { get; protected set; } = "Eat";
    public override int Cost { get; protected set; } = 5;
    public override GoapState PreCondition { get; protected set; } = new GoapState(new Dictionary<string, int>() {
        { AIStateKey2.SitDown,1 },
    });
    public override GoapState Effect { get; protected set; } = new GoapState(new Dictionary<string, int>()
    {
        {AIStateKey2.Eat,1 },
    });

    public override GoapAgent Agent { get; protected set; }

    public GameObject Target { get; protected set; }


    private Chair Chair;

    public EatAction(GoapAgent goapAgent) : base(goapAgent)
    {

    }


    public override void OnStart()
    {
        base.OnStart();

    }

    public override void OnDone()
    {
        base.OnDone();

        ((AIAgent)Agent).Chair.IsHasPeople = false;
        ((AIAgent)Agent).Chair = null;
    }

    private float time = 2f;

    public override void OnUpdate()
    {
        base.OnUpdate();

        if (time > 0)
        {
            time -= Time.deltaTime;
            Progress = (1 - (time / 2f));
            if (time <= 0)
            {
                Agent.GoapState.SetValue(AIStateKey2.Eat, 1);
            }
        }

    }

}